let mut expanded_list = Vec::new();
for path in list {
- let expanded_paths = expand_member_path(&path, root)?;
- expanded_list.extend(expanded_paths);
+ let pathbuf = root.join(path);
+ let expanded_paths = expand_member_path(&pathbuf)?;
+
+ // If glob does not find any valid paths, then put the original
+ // path in the expanded list to maintain backwards compatibility.
+ if expanded_paths.is_empty() {
+ expanded_list.push(pathbuf);
+ } else {
+ expanded_list.extend(expanded_paths);
+ }
}
for path in expanded_list {
}
}
-fn expand_member_path(member_path: &str, root_path: &Path) -> CargoResult<Vec<PathBuf>> {
- let path = root_path.join(member_path);
+fn expand_member_path(path: &Path) -> CargoResult<Vec<PathBuf>> {
let path = path.to_str().unwrap();
let res = glob(path).map_err(|e| {
human(format!("could not parse pattern `{}`: {}", &path, e))
}
#[test]
-fn glob_syntax_non_cargo_folder() {
+fn glob_syntax_invalid_members() {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
.file("crates/bar/src/main.rs", "fn main() {}");
p.build();
- assert_that(p.cargo("build"), execs().with_status(0));
- assert_that(&p.bin("foo"), existing_file());
- assert_that(&p.bin("bar"), is_not(existing_file()));
+ assert_that(p.cargo("build"),
+ execs().with_status(101)
+ .with_stderr("\
+error: failed to read `[..]Cargo.toml`
- assert_that(&p.root().join("Cargo.lock"), existing_file());
+Caused by:
+ [..]
+"));
}